
package com.market.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.market.bean.Scroll;
import com.market.dao.hibernate.GenericDaoHibernate;

/**
 * Data access object (DAO) for domain model class Scroll.
 * 
 * @see com.market.bean.Scroll
 * @author MyEclipse - Hibernate Tools
 */
public class ScrollDAO extends GenericDaoHibernate<Scroll, Long>  implements IScrollDAO
{

    public ScrollDAO(Class<Scroll> persistentClass)
    {
        super(persistentClass);
        // TODO Auto-generated constructor stub
    }

    public ScrollDAO()
    {
        super();
    }
    
    private static final Logger log = LoggerFactory.getLogger(ScrollDAO.class);

    private static final String GET_LIST = "select new Product(p.id,p.category,p.name,p.standard, p.price,p.vipprice,p.dprice,p.description,p.adddate,p.hot,p.type,p.pic,p.unit) from Scroll s ,Product p where s.id=p.id";

    // property constants

    protected void initDao()
    {
        // do nothing
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.market.dao.IScrollDAO#findById(java.lang.Long)
     */
    public Scroll findById(long id)
    {
        log.debug("getting Scroll instance with id: " + id);
        try
        {
            Scroll instance = (Scroll)getHibernateTemplate().get("com.market.bean.Scroll", new Long(id));
            return instance;
        }
        catch (RuntimeException re)
        {
            log.error("get failed", re);
            throw re;
        }
    }

    public List getScrollList()
    {
        return getHibernateTemplate().find(GET_LIST);
    }
}
